<template>
   <div
    class="tools"
    v-loading="$store.getters.loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="#a19f9fb0;"
  >
    <lb-layout>
      <aps-form
        :config="apsForm.formConfig"
        :model="apsForm.formData"
        :formRef="apsForm.formRef"
        :labelWidth="apsForm.labelWidth"
        ref="form"
      ></aps-form>
    </lb-layout>
  </div>
</template>

<script>
import { getMCood } from "@/api/tool/tools";
export default {
  name: "tools",
  data() {
    return {
      apsForm: {
        formRef: "form",
        formData: {},
        formConfig: {
          formAttr: {
            // inline: true,
            size: "small",
            "label-position": "right",
            size: "small",
            bsColumn: {
              col: 1,
              middle: true,
            },
          },
          properties: {
            //这里是渲染查询表单的表头和类型的数据
            originalname: {
              typeName: "el-input",
              label: "原坐标:",
              placeholder: "请输入原坐标",
            },
            mcood: {
              typeName: "aps-des",
              label: "目标坐标:"
            },
          },
          formSoltButton: [
            {
              label: "提交",
              type: "primary",
              typeName: "el-button",
              size: "small",
              icon: "el-icon-finished",
              click: this.handleSubmit,
            }
          ],
        },
      },
    };
  },
  mounted() {
  },
  methods: {
     handleSubmit() {
      let that = this;
      this.$refs.form.validate((valid, err) => {
        if (valid) {
          let params = { ...that.$refs.form.getFieldsValue() };
            this.$store.commit("app/updateApiCount", "add");
            getMCood(params)
              .then((res) => {
                this.$store.commit("app/updateApiCount");
                that.$refs?.form?.setFieldValue('mcood',res);
              })
              .catch((err) => {
                this.$store.commit("app/updateApiCount");
                // this.$message.error("系统错误,请联系管理员!40001");
              });
        } else {
          return false;
        }
      });
    },
    handleReset() {
      this.$router.go(-1);
    },
  },
};
</script>

<style scoped lang="scss">
@import "~@/assets/styles/middle.scss";
.tools {
  @include aps-middle;
  ::v-deep .aps-middle-footer {
    text-align: center;
    .el-form-item__content {
      margin-left: 0;
    }
  }
}
</style>
